<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="/public/bootstrap/css/bootstrap.css">
    <link rel="stylesheet" href="/css/home.css">
    <script src="/public/jquery/jquery.js"></script>
    <script src="/public/bootstrap/js/bootstrap.js"></script>
    <script src="/public/qiniu/qiniu.min.js"></script>
    <script src="/util/ajax.js"></script>
    <script src="/public/template/template.js"></script>

    <title>管理详情页</title>
</head>

<body>

    <nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                </button>
                <a class="navbar-brand" href="#">简易管理系统</a>
            </div>
            <div id="navbar" class="navbar-collapse collapse">
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="#">设置</a></li>
                    <li id="userDetail"><a href="#">用户</a></li>
                    <li id="userDetailAvatar"> <img src="" alt=""></li>
                    <li id='clearUserBackLogin'><a href="/?ha=exit">退出</a></li>
                </ul>
                <form class="navbar-form navbar-right">
                    <input type="text" class="form-control" placeholder="搜索 - - - " id="searchUser">
                </form>
            </div>
        </div>
    </nav>
    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-12 col-md-12 main">
                <div class="row placeholders" id="imgWrapper">
                    <script id="imgList" type="text/html">
                        {{each userObj item}}
                        <div class="col-xs-6 col-sm-3 placeholder">
                            <img src="{{item.avatar}}" width="200" height="200" class="img-responsive" alt="Generic placeholder thumbnail">
                            <h5>{{item.name}}</h5>
                        </div>
                        {{/each}}
                    </script>
                </div>
            </div>
        </div>
    </div>
    <div class="container-fluid">
        <div class="btn-group m-20" role="group">
            <button id="showAddDialogBtn" type="button" class="btn btn-primary">新增用户</button>
            <button type="button" id="showUpdateDialogBtn" class="btn btn-danger" disabled>修改用户</button>
            <button type="button" id="showDelDialogBtn" class="btn btn-warning" disabled>删除用户</button>
        </div>
        <div class="table-responsive">
            <table class="table table-striped table-bordered table-hover">
                <thead>
                    <tr class="thead-color">
                        <th>
                            <input class="check-all" type="checkbox">
                        </th>
                        <th>姓名</th>
                        <th>年龄</th>
                        <th>性别</th>
                        <th>学历</th>
                        <th>爱好</th>
                    </tr>
                </thead>
                <tbody>
                    <script id="tableWrapper" type="text/html">
                        {{each userObj item}}
                        <tr>
                            <td>
                                <input id="{{item._id}}" class="check-one" type="checkbox">
                            </td>
                            <td>{{item.name}}</td>
                            <td>{{item.age}}</td>
                            <td>{{item.gender == 0?'女':'男'}}</td>
                            <td>{{item.edu}}</td>
                            <td>{{item.hobbies}}</td>
                        </tr>
                        {{/each}}
                    </script>
                </tbody>
            </table>
            <nav aria-label="Page navigation">
                <ul class="pagination">
                    <li id="userListPagePrev">
                        <span>&laquo;</span>
                    </li>
                    <ul id='userListPage'>

                    </ul>
                    <li id="userListPageNext">
                        <span>&raquo;</span>
                    </li>
                </ul>
            </nav>
        </div>
    </div>

    <!-- 模态框 -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close close-btn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">新增用户</h4>
                </div>
                <div class="modal-body">
                    <form id="dialogForm" class="form-horizontal">
                        <div class="form-group">
                            <label for="inputEmail3" class="col-sm-2 control-label">姓名</label>
                            <div class="col-sm-5">
                                <input type="text" class="form-control" id="name" placeholder="请输入姓名">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputPassword3" class="col-sm-2 control-label">年龄</label>
                            <div class="col-sm-5">
                                <input type="text" class="form-control" id="age" placeholder="请输入年龄">
                            </div>
                        </div>
                        <div class="form-group" id="gender">
                            <label for="inputPassword3" class="col-sm-2 control-label">性别</label>
                            <div class="col-sm-5">
                                <label class="radio-inline">
                                             <input type="radio" name="gender"  value="1"> 男
                                    </label>
                                <label class="radio-inline">
                                   <input type="radio" name="gender" value="0"> 女
                                </label>
                            </div>
                        </div>

                        <div class="form-group" id="hobbies">
                            <label for="inputPassword3" class="col-sm-2 control-label">爱好</label>
                            <div class="col-sm-5">
                                <label class="checkbox-inline">
                                    <input type="checkbox" name="hobbies" value="1"> 抽烟
                                    </label>
                                <label class="checkbox-inline">
                                    <input type="checkbox" name="hobbies" value="2"> 喝酒
                                    </label>
                                <label class="checkbox-inline">
                                    <input type="checkbox" name="hobbies" value="3"> 汤头
                                    </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputPassword3" class="col-sm-2 control-label">学历</label>
                            <div class="col-sm-5">
                                <select id="edu" class="form-control">
                                        <option  value="-1">请选择</option>
                                        <option value="2">小学</option>
                                        <option value="3">中学</option>
                                        <option  value="4">大学</option>
                                 </select>
                            </div>
                        </div>
                        <div class="upload-img-wrapper">
                            +
                            <input id="avatar" type="file">
                            <img src="" alt="">
                        </div>
                        <input id="reset" type="reset" style="display: none">
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="closeBtn">关闭</button>
                    <button type="button" class="btn btn-primary close-btn" id="changeBtn">添加用户</button>
                </div>
            </div>
        </div>
    </div>

    <!--删除模态框-->

    <div class="modal fade" id="myDelModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close close-btn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">提示</h4>
                    <h5 style="margin-top:30px;margin-bottom: 30px;">确认删除该用户吗?</h5>
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="closeBtn">取消</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="closeUser">确认</button>
                </div>
            </div>
        </div>
    </div>
    <script src="/common/upload.js"></script>
    <script src="/js/home.js"></script>
    <script>
        let localStorageUserName = localStorage.getItem('user_name')
        let localStorageUserAvatar = localStorage.getItem('user_avatar')
        $('#userDetail a').html(localStorageUserName)
        $('#userDetailAvatar  img').attr('src', localStorageUserAvatar)
    </script>
</body>

</html>